'''输入一个文件和一个字符，统计该字符在文件中出现的次数。'''
compar = input('请输入任意一个字符：')
txt = ''
counts = 0
f = open('try.txt','r',encoding = 'utf-8').read()    #导入文档
for line in f:
    txt = txt + str(line)
print('“{}”共出现了{}次'.format(compar,txt.count(compar)))
